package com.service.log;


import com.common.PageResultUtil;
import com.entity.OperationLog;
import com.facade.log.IOperationLogFacadeR;
import com.mapper.CustomMapper;
import com.mapper.OperationLogMapper;
import com.query.IQueryComplex;
import com.service.CustomServiceR;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class OperationLogServiceR extends CustomServiceR<OperationLog> implements IOperationLogFacadeR {

    @Resource
    private OperationLogMapper mapper;

    @Override
    protected CustomMapper<OperationLog> initMapper() {
        return mapper;
    }

    @Override
    public PageResultUtil<OperationLog> queryOperationLogPageLink(IQueryComplex query) {
        PageResultUtil<OperationLog> pageResultUtil = new PageResultUtil<>();
        Map<String, Object> params = query.params();
        int count = mapper.queryOperationLogCountLink(params);
        createPageParamForQueryLink(params, count, query.getStart(), query.getLength(), pageResultUtil);

        if (count > 0) {
            List<OperationLog> retList = mapper.queryOperationLogPageLink(params);
            pageResultUtil.setItems(retList);
        }
        return pageResultUtil;
    }

}